package com.nameless.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameless.dao.CarTypeConfigDetailsMapper;
import com.nameless.entity.CarTypeConfigDetails;
import com.nameless.service.CarTypeConfigDetailsService;
import com.nameless.vo.CarTypeConfigVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：潘淼淼
 * @date ：Created in 2023/2/27 9:35
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class CarTypeConfigDetailsServiceImpl extends ServiceImpl<CarTypeConfigDetailsMapper, CarTypeConfigDetails> implements CarTypeConfigDetailsService {
    @Resource
    private CarTypeConfigDetailsMapper carTypeConfigDetailsMapper;

    //查询
    @Override
    public Result queryTypeConfig(CarTypeConfigVo carTypeConfigVo) {
        PageHelper.startPage(carTypeConfigVo);
        List<CarTypeConfigDetails> carTypeConfigDetails = carTypeConfigDetailsMapper.queryAllConfig(carTypeConfigVo);
        PageInfo<CarTypeConfigDetails> info = new PageInfo<>(carTypeConfigDetails);
        return new Result(200, "查询所有成功", info);
    }


    // 修改
    @Override
    public Result updateAll(CarTypeConfigDetails carTypeConfigDetails) {
        int i = carTypeConfigDetailsMapper.updateById(carTypeConfigDetails);
//        int update = carTypeConfigDetailsMapper.update(carTypeConfigDetails);
        return new Result(200, "修改所有成功", i);
    }

    @Override
    public Result deleteById(Integer id) {
        int delete = carTypeConfigDetailsMapper.delete(id);
        return new Result(200, "删除所有成功", delete);
    }

    @Override
    public Result addOne(CarTypeConfigDetails carTypeConfigDetails) {
        int insert = carTypeConfigDetailsMapper.insert(carTypeConfigDetails);
        return new Result(200, "添加所有成功", insert);
    }

    @Override
    public Result queryType() {
        List<CarTypeConfigDetails> carTypeConfigDetails = carTypeConfigDetailsMapper.selectList(null);
        return new Result(200, "查询成功", carTypeConfigDetails);
    }

    @Override
    public List<CarTypeConfigDetails> getTypeConfigAll() {
        List<CarTypeConfigDetails> carTypeConfigDetails = carTypeConfigDetailsMapper.selectList(null);
        return carTypeConfigDetails;
    }
}